var express = require('express');
var router = express.Router();


const http = require('http');
const mysql = require('mysql');
const url = require('url');

var TEST_DATABASE = 'bigevent';  
var TEST_TABLE = 'bigevent'; 

var con = mysql.createConnection({
    host: 'localhost',
    user:'root',
    password:'694310908',
    database:TEST_DATABASE
});

function onRequest(req,rep){
    console.log('Someone is writing Artical');
 

    
    var date = req.body.date;
    var type = req.body.type;
    var name = req.body.name;
    var summary =req.body.summary;
    var detail = req.body.detail;
    var postimg = req.body.postimg;

    con.query('insert into bigevent(date,type,name,summary,detail,postimg) value (?,?,?,?,?,?);',[date,type,name,summary,detail,postimg],function(e,sqlres,f){
        console.log(sqlres);

    });
    rep.end("1");
}
router.post('/',onRequest);

module.exports=router;